home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 April / PCWorld_2008-04_cd.bin / v cisle / ozo / zotero-1.0.3.xpi / chrome / zotero.jar / content / zotero / selectItemsDialog.js < prev    next >
Encoding:
JavaScript  |  2008-01-29  |  2.7 KB  |  105 lines

  1. /*
  2.     ***** BEGIN LICENSE BLOCK *****
  3.     
  4.     Copyright (c) 2006  Center for History and New Media
  5.                         George Mason University, Fairfax, Virginia, USA
  6.                         http://chnm.gmu.edu
  7.     
  8.     Licensed under the Educational Community License, Version 1.0 (the "License");
  9.     you may not use this file except in compliance with the License.
  10.     You may obtain a copy of the License at
  11.     
  12.     http://www.opensource.org/licenses/ecl1.php
  13.     
  14.     Unless required by applicable law or agreed to in writing, software
  15.     distributed under the License is distributed on an "AS IS" BASIS,
  16.     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17.     See the License for the specific language governing permissions and
  18.     limitations under the License.
  19.     
  20.     ***** END LICENSE BLOCK *****
  21. */
  22.  
  23. var itemsView;
  24. var collectionsView;
  25. var io;
  26.  
  27. /*
  28.  * window takes two arguments:
  29.  * io - used for input/output (dataOut is list of item IDs)
  30.  * sourcesOnly - whether only sources should be shown in the window
  31.  */
  32. function doLoad()
  33. {
  34.     // Set font size from pref
  35.     var sbc = document.getElementById('zotero-select-items-container');
  36.     Zotero.setFontSize(sbc);
  37.     
  38.     io = window.arguments[0];
  39.     
  40.     collectionsView = new Zotero.CollectionTreeView();
  41.     document.getElementById('zotero-collections-tree').view = collectionsView;
  42.     
  43.     // move to center of screen
  44.     window.sizeToContent();
  45.     window.centerWindowOnScreen();
  46. }
  47.  
  48. function doUnload()
  49. {
  50.     collectionsView.unregister();
  51.     if(itemsView)
  52.         itemsView.unregister();
  53. }
  54.  
  55. function onCollectionSelected()
  56. {
  57.     if(itemsView)
  58.         itemsView.unregister();
  59.  
  60.     if(collectionsView.selection.count == 1 && collectionsView.selection.currentIndex != -1)
  61.     {
  62.         var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex);
  63.         collection.setSearch('');
  64.         
  65.         try {
  66.             Zotero.UnresponsiveScriptIndicator.disable();
  67.             itemsView = new Zotero.ItemTreeView(collection, (window.arguments[1] ? true : false));
  68.             document.getElementById('zotero-items-tree').view = itemsView;
  69.         }
  70.         finally {
  71.             Zotero.UnresponsiveScriptIndicator.enable();
  72.         }
  73.         
  74.         if (collection.isLibrary()) {
  75.             Zotero.Prefs.set('lastViewedFolder', 'L');
  76.         }
  77.         if (collection.isCollection()) {
  78.             Zotero.Prefs.set('lastViewedFolder', 'C' + collection.ref.getID());
  79.         }
  80.         else if (collection.isSearch()) {
  81.             Zotero.Prefs.set('lastViewedFolder', 'S' + collection.ref.id);
  82.         }
  83.     }
  84. }
  85.  
  86. function onSearch()
  87. {
  88.     if(itemsView)
  89.     {
  90.         var searchVal = document.getElementById('zotero-tb-search').value;
  91.         itemsView.setFilter('search', searchVal);
  92.         
  93.         document.getElementById('zotero-tb-search-cancel').hidden = searchVal == "";
  94.     }
  95. }
  96.  
  97. function onItemSelected()
  98. {
  99.     
  100. }
  101.  
  102. function doAccept()
  103. {
  104.     io.dataOut = itemsView.getSelectedItems(true);
  105. }